/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.core;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.core.Page;

import java.util.Collection;
import java.util.List;

/**
 * <p>DAO for pages. It contains methods common for both content and action pages</p>
 * <p><a href="PageDAO.java.html"><i>View Source</i></a></p>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.21 $ $Date: 2008/01/14 15:54:32 $
 */
public interface PageDAO extends LocalizableDAO {

	// ~ Common methods

	/**
	 * Retrieves page despite its type
	 *
	 * @param pageId ID of page to retrieve
	 * @return Page or null if nothing was found
	 */
	public Page retrievePage(Long pageId);

	/**
	 * Finds page (no matter action or content) by its URI
	 *
	 * @param uri URI of page to search by
	 * @return Page or null if nothing was found
	 */
	public Page findPageByUri(String uri);

	/**
	 * Updates page
	 *
	 * @param page page for update
	 */
	public void updatePage(Page page);

    /**
	 * Returns collection of pages regardless of their type. Only active pages
     * are returned.
	 *
	 * @param queryInfo Object with some information for query
	 * @return Collection of pages
	 */
	public PartialCollection listPages(QueryInfo queryInfo);

    /**
	 * Returns collection of linkable items, which are not content nor action pages
	 *
	 * @param queryInfo Object with some information for query
	 * @return Collection of linkable items
	 */
	public PartialCollection listLinkableItems(QueryInfo queryInfo);

    /**
     * Returns list of all pages fetching their fields and values
     *
     * @return list of pages, each of them with fields, each of fields with field values
     */
    public Collection listPagesFetching();

    /**
	 * Returns list of last modified pages.
	 *
	 * @param queryInfo Object with some information for query
	 * @return List of pages
	 */
	public List getLastPages(QueryInfo queryInfo);

    /**
     * Takes a list of pages and returns list of
     * {@link com.blandware.atleap.persistence.util.PageAndAnnotation} instances
     * where each instance corresponds to element in initial list. In the list,
     * annotation is value of 'annotation' field for corresponding page in
     * language with specified locale identifier.
     *
     * @param list              list of pages
     * @param localeIdentifier  identifier of language
     * @return list of PageAndAnnotation instances
     */
    public List getPagesAnnotations(List list, String localeIdentifier);

    /**
	 * Searches for duplicates. Returns <code>true</code> if there is one or more pages with another ID, but which
	 * have same values from some set (e.g. uri)
	 *
	 * @param page Page to search duplicates for
	 * @return whether given page has duplicates
	 */
	public boolean hasDuplicates(Page page);

    /**
     * Removes associations of a Page with other objects (usually, this is made
     * before deletion). Here, non-cascadable associations should be removed.
     *
     * @param page page from which to remove associations
     */
    public void removeAssociations(Page page);
}
